
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*; 
import java.io.*;
import java.util.*;

public class WarningFrame extends JPanel {


	/**
	 * 
	 */
	private static final long serialVersionUID = 8112429290602083610L;

	String warning;

	JTextArea warn;
	PolicyFrame parent;
	
	public WarningFrame(){
		super(new FlowLayout(FlowLayout.CENTER));
		warning="";
		parent=null;
	}
	
	public WarningFrame(PolicyFrame p){
		super(new FlowLayout(FlowLayout.CENTER));
		warning="";
		parent=p;
	}
	
	public void setParent(PolicyFrame p){
		parent=p;
	}
	
	public void config(){
		warn=new JTextArea(37,60);
		warn.setEditable(false);
		warn.setLineWrap(true);
		JScrollPane sp=new JScrollPane(warn);
		sp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		JLabel cLabel=new JLabel("<html><body>Warning<br></body></html>");
		JPanel p1=new JPanel(new FlowLayout(FlowLayout.LEFT));
		p1.add(cLabel);
		JPanel p2=new JPanel(new BorderLayout());
		p2.add(p1,"North");
		p2.add(sp,"Center");
		
		add(p2);
	}
	
	public void refresh(){
		parent.flushData();
		constructWarning();
		warn.setText(warning);
	}
	
	public void constructWarning(){
		warning="";
		PolicyProperty pp=parent.property.pp;
		if(pp.policyName.replaceAll(" ", "").equals("")){
			warning=warning+"Required attribute: policy name not present\n";
		}
		if(pp.readablePolicyUrl.replaceAll(" ", "").equals("")){
			warning=warning+"Required attribute: human-readable privacy policy not present\n";
		}
	}
}
